home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / elf11.zip / ELF.A86 next >
Text File  |  1988-08-07  |  4KB  |  108 lines

  1. ;************************************************************************
  2. ;*                                    *
  3. ;*    ELF.A86.  This stupid program will set the specified error level*
  4. ;*    for batch files.  It has two modes of operation:  If invoked by:*
  5. ;*    ELF <CR> it will display: (Y/N)? on the screen & wait for one    *
  6. ;*    of these keys to be pressed.  It will then exit with errorlevel *
  7. ;*    255 if N was pressed, or error level 0 if Y was pressed.  With    *
  8. ;*    careful editing of prompts in a batch file, this can be used    *
  9. ;*    to make run-time operator decisions in batch files.        *
  10. ;*    The second invocation is:  ELF XX <CR>    Where XX is a two digit *
  11. ;*    HEXIDECIMAL number.  ELF will terminate with the specified    *
  12. ;*    error level.  This can add error level processing to programs    *
  13. ;*    that do not support it by chaining to ELF upon termination.    *
  14. ;*    Remember that the batch file ERRORLEVEL command only accepts    *
  15. ;*    decimal radix arguments.  Hex was used for ELF out of pure    *
  16. ;*    laziness on the part of the programmer!             *
  17. ;*    Written by:  Mark D. Pickerill    9 Sept. 1988.  The user bears    *
  18. ;*    all responsiblity for testing & use.  ELF stands for (E)rror    *
  19. ;*    (L)evel (F)ile, although the name was inspired by Tolkien,    *
  20. ;*    more than anything else.  COSMAC users take note!        *
  21. ;*                                    *
  22. ;************************************************************************
  23.                 ;
  24. CR:    EQU    0DH        ; Carriage return
  25. LF:    EQU    0AH        ; Line feed
  26. EOF:    EQU    1AH        ; End of file
  27.                 ;
  28.     ORG    0100H        ; Start of tpa
  29.                 ;
  30. ELF:    JMP    START        ; Jump past ego section
  31.                 ;
  32.     DB    CR,LF,'ELF, Error Level File'
  33.     DB    CR,LF,'By M.D.P. 9 Sept. 1988',EOF
  34.                 ;
  35. START:    PUSH    CS        ; Set data segment
  36.     POP    DS        ; It's set
  37.     PUSH    DS        ; Get this segment
  38.     POP    ES        ; And set es as well
  39.     MOV    SI,0080H    ; Point to parameter field in psp
  40.     MOV    CL,[SI]        ; Get parameter length
  41.     OR    CL,CL        ; Force flags
  42.     JZ    NOPARMS        ; Do y/n
  43.     MOV    CH,00H        ; Zero ch
  44. LOOP1:    INC    SI        ; Point to start of parameters
  45.     MOV    AL,[SI]        ; Get byte from parameter field
  46.     CMP    AL,' '        ; Space?
  47.     LOOPZ    LOOP1        ; Wait until you get a non-space char
  48.     JZ    NOPARMS        ; Do y/n
  49.     MOV    AH,AL        ; Get hex char
  50.     INC    SI        ; Next hex char
  51.     MOV    AL,[SI]        ; Get lsn
  52.     CALL    GETHEX        ; Convert to hex
  53.     XCHG    AH,AL        ; Store & retrieve msn
  54.     CALL    GETHEX        ; Convert
  55.     XCHG    AH,AL        ; Switch back
  56.     ADD    AH,AH        ; Compensate upper nybble
  57.     ADD    AH,AH        ;
  58.     ADD    AH,AH        ;
  59.     ADD    AH,AH        ; Ok, i`m tired of rotates!
  60.     OR    AL,AH        ; Ok we now have our number
  61.     MOV    AH,4CH        ; Mush dos terminate
  62.     INT    21H        ; Terminate with specified error level
  63.                 ;
  64. GETHEX:    CMP    AL,2FH        ; <2f?
  65.     JL    TERM        ; Control, ignore
  66.     CMP    AL,46H        ; >46?
  67.     JG    TERM        ; Upper-case g or above, ignore
  68.     CMP    AL,39H        ; <39?
  69.     JLE    NUMBER        ; It's a number
  70.     CMP    AL,41H        ; <41?
  71.     JL    TERM        ; It's a punctuation, etc; ignore
  72. LETTER:    ADD    AL,09H        ; 9 makes the lsn=hex version of input
  73. NUMBER:    AND    AL,0FH        ; Strip msn, makes numbers hex & dumps
  74.                 ; Useless msn for letters
  75.     RET            ; Near
  76.                 ;
  77. TERM:    MOV    AX,4C01H    ; Garbage parameters
  78.     INT    21H        ;
  79.                 ;
  80. MESSAGE:DB    '(Y/N)?$'    ; Question
  81.                 ;
  82. NOPARMS:MOV    AH,09H        ; Print string function
  83.     LEA    DX,MESSAGE    ; Point
  84.     INT    21H        ; Do it
  85. NOPE:    MOV    AH,01H        ; Console input
  86.     INT    21H        ; Get char
  87.     AND    AL,5FH        ; Make upper case
  88.     CMP    AL,'Y'        ; Yes?
  89.     JZ    YES        ; Yes
  90.     CMP    AL,'N'        ; No?
  91.     JZ    NO        ; Yes
  92.     JMP    NOPE        ; Garbage, ignore
  93.                 ;
  94. YES:    CALL    CRLF        ;SEND CRLF
  95.     MOV    AX,4C00H    ; Error level 0 for yes
  96.     INT    21H        ; We're history
  97. NO:    CALL    CRLF        ;SEND CRLF
  98.     MOV    AX,4CFFH    ; Error level ff for no
  99.     INT    21H        ; We're history
  100. CRLF:    MOV    AH,02H        ;CONOUT FUNCTION
  101.     MOV    DL,0DH        ;SEND CR
  102.     INT    21H        ;DO IT
  103.     MOV    AH,02H        ;CONOUT FUNCTION
  104.     MOV    DL,0AH        ;SEND LF
  105.     INT    21H        ;DO IT
  106.     RET            ;NEAR
  107.     END            ;
  108.